#include<stdio.h>
#include<queue>
#include<iostream>
using namespace std;
int main()
{
	queue<int>s1;
	int count=0,n,m,a[1000],b[1000],c,i,k,j=0;
	cin>>n>>m;
	if(m>n){
		cout<<"error!";
		return 0;
	}
	for(i=0;i<n;i++){
		a[i]=i+1;
		s1.push(a[i]);
		count++;
	}
	while(count>=1){
		for(k=0;k<m-1;k++){
			c=s1.front(); 
			s1.pop();
			s1.push(c);
		}
		b[j++]=s1.front();
		s1.pop();
		count--;
		if(count<m){
			for(i=0;i<count;i++){
				b[j++]=s1.front();
				s1.pop();
				count--; 
			}
		} 
	}
	for(k=0;k<j-1;k++){
		cout<<b[k]<<" ";
	}
	cout<<b[k];
}
